package com.JohnCarloSalter.Receipt;

import java.util.Calendar;

public class GeorgiaTax implements SalesTax {

	private final double TAX_RATE = .04;
	
	public double getSalesTax(Calendar d, double price) {
		if(isTaxFreeDay(d)) {
			if(price > 1000) {
				return ((price - 1000) * TAX_RATE); 
			} else {
				return 0;
			}
		} else {
			return (price * TAX_RATE);
		}
	}
	
	//Returns true if the date is the first Friday or Saturday of August. 
	private boolean isTaxFreeDay(Calendar d) {
		return d.get(Calendar.MONTH) == d.get(Calendar.AUGUST) && 
				d.get(Calendar.DAY_OF_MONTH) < 8 &&
				(d.get(Calendar.DAY_OF_WEEK) == d.get(Calendar.FRIDAY) 
				|| d.get(Calendar.DAY_OF_WEEK) == d.get(Calendar.SATURDAY));
	}

}
